
#ifndef __QE_INTERRUPT_H__
#define __QE_INTERRUPT_H__



#include "qe_device.h"



/* Interrupt handler type */
typedef void (*qe_irq_handler)(void *);



/* Interrupt type */
#define QE_IRQ_EDGE_RISE        0x01
#define QE_IRQ_LEVEL_HIGH       0x02
#define QE_IRQ_EDGE_FALL        0x04
#define QE_IRQ_LEVEL_LOW        0x08
#define QE_IRQ_LEVEL_MASK       0x10



struct qe_intc_device;
typedef struct qe_intc_device qe_intc_dev;

typedef struct
{
    qe_ret (*irq_register)(qe_intc_dev *dev, qe_int irq, qe_irq_handler handler, void *args);
    void   (*irq_unregister)(qe_intc_dev *dev, qe_int);
    qe_ret (*irq_enable)(qe_intc_dev *dev, qe_int);
    void   (*irq_disable)(qe_intc_dev *dev, qe_int);
} qe_intc_ops;

typedef struct qe_intc_device
{
    qe_dev dev;
    qe_intc_ops *ops;
} qe_intc_dev;

qe_ret qe_intc_register(qe_intc_dev *intc, qe_const_str name, qe_intc_ops *ops);

qe_ret qe_intc_irq_register(qe_intc_dev *intc,
    qe_int irq, qe_irq_handler handler, void *args);

void qe_intc_irq_unregister(qe_intc_dev *intc, qe_int irq);

qe_ret qe_intc_irq_enable(qe_intc_dev *intc, qe_int irq);

void qe_intc_irq_disable(qe_intc_dev *intc, qe_int irq);

#if (CONFIG_PORT_INTERRUPT_MGMT)
qe_ret qe_irq_enable(int irq);

void qe_irq_disable(int irq);

qe_ret qe_irq_register(int irq, qe_irq_handler handler, void *args);

void qe_irq_unregister(int irq);

void qe_irq_set_priority_trigger_type(qe_u32 irq, qe_u8 prior, qe_u8 trigger);
#endif

void qe_intc_mount(qe_irq_handler handler, void *args);

qe_const_str qe_of_get_interrupt_parent_name(const void *fdt, qe_u32 offset);

#endif /* __QE_INTERRUPT_H__ */

